<?php


namespace app\api\model;


use think\Model;

class UserFoodModel extends Model
{
    // 表名
    protected $name = 'user_food';
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    protected $append = ['food_attr'];

    public function getFoodAttrAttr($val,$data)
    {
        $attr = UserFoodAttrModel::all(['pid'=>$data['id']]);
        return $attr;
    }
}